package com.vgooo.client.tool;

import java.util.HashMap;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.umeng.analytics.MobclickAgent;
import com.umeng.fb.UMFeedbackService;
import com.umeng.fb.util.FeedBackListener;
import com.vgooo.bean.UserInfo;
import com.vgooo.client.Main;
import com.vgooo.client.R;
import com.vgooo.client.VGActivity;
import com.vgooo.client.VGApplication;
import com.vgooo.client.ViewLayout;
import com.vgooo.client.vchannel.player.VideoPlayerActivity;

public class ToolMainActivity extends VGActivity {
	
//	private String url = "http://101.226.245.81/youku/657200B4C4537831186769673F/0300200100516B382FCAC504E9D2A74500146C-D889-7179-8022-3746A70B489A.mp4" ;
	private String  url = "http://m.youku.com/smartphone/pvs?vid=XNTM5NDg0OTc2&format=3gphd&cid=92&stat_down_=1" ;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tool_main);
	}
	
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		// 友盟统计功能，打开页面
		MobclickAgent.onResume(this);
		super.onResume();
	}
	
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		// 友盟统计功能，页面关闭
		MobclickAgent.onPause(this);
		super.onPause();
	}

	@Override
	public void initView() {
		// TODO Auto-generated method stub

	}

	@Override
	public void setupView() {
		// TODO Auto-generated method stub

	}

	@Override
	public void addListener() {
		// TODO Auto-generated method stub

	}

	@Override
	public void flashView() {
		// TODO Auto-generated method stub

	}

	@Override
	public void getData() {
		// TODO Auto-generated method stub

	}

	@Override
	public void doClick(View v) {
		// TODO Auto-generated method stub
		Intent intent = new Intent();
		// TODO Auto-generated method stub
		switch (v.getId()) {


		case R.id.tool_main_feedback:
			//条用友盟意见反馈功能
			UserInfo userInfo = VGApplication.userInfo;
			if(null!=userInfo&&null!=userInfo.user_id){
				UMFeedbackService.setFeedBackListener(new MyFeedBackListener());
			}
			UMFeedbackService.openUmengFeedbackSDK(this);
			log("doClick()  你单击了=>”意见反馈“");
			break ;
		case R.id.tool_main_branch_query:
			log("doClick()  你单击了=>”店铺查询“");
			ViewLayout.setViewPre(true, "店铺查询", ViewLayout.TAB_TAG_BRANCHS_MAIN,cparent);
			break ;
		case R.id.tool_main_phone_test:
			log("doClick()  你单击了=>”手机测试“");
			ViewLayout.setViewPre(true, "手机测试", ViewLayout.TAB_TAG_TEST_MAIN,cparent);
			break ;
		case R.id.tool_main_player:
			playVideo(url);
			log("doClick :" + url);
//			intent = new Intent(this, VideoPlayerActivity.class);
//			intent.setAction(Intent.ACTION_VIEW) ;
//			Uri uri = Uri.parse(url);
//			intent.setDataAndType(uri, "video/*") ;
//			startActivity(intent);
			 break ;
			
		default:
			log("doClick() 未定义控件单击后的事件......" + v.getId());
			break;
		}
	}
	
	
	private class MyFeedBackListener implements FeedBackListener{

		@Override
		public void onResetFB(Activity activity,
	            Map<String, String> contactMap,
	            Map<String, String> remarkMap) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void onSubmitFB(Activity activity) {
			// TODO Auto-generated method stub
			Map<String,String> remarkMap  = new HashMap<String, String>();
			remarkMap .put("id", VGApplication.userInfo.user_id);
			UMFeedbackService.setRemarkMap(remarkMap );
		}
		
	}
	
	/**
	 * 打印调试信息
	 * 
	 * @param info
	 */
	private   void log(String info) {
		Log.i(this.getClass().getSimpleName(), info);
	}

}
